package org.jeecg.modules.health_records.health_mar.service.impl;

import org.jeecg.modules.health_records.health_mar.entity.HealthMarInfo;
import org.jeecg.modules.health_records.health_mar.mapper.HealthMarInfoMapper;
import org.jeecg.modules.health_records.health_mar.service.IHealthMarInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description: 用药记录表
 * @Author: jeecg-boot
 * @Date:   2025-07-02
 * @Version: V1.0
 */
@Service
public class HealthMarInfoServiceImpl extends ServiceImpl<HealthMarInfoMapper, HealthMarInfo> implements IHealthMarInfoService {
    @Autowired
    private HealthMarInfoMapper healthMarInfoMapper;
    /**按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthMarInfo> queryByRecordId(HealthMarInfo healthMarInfo) {
        return healthMarInfoMapper.queryByRecordId(Long.valueOf(healthMarInfo.getRecordid()), healthMarInfo.getIdNumber());

    }

    /**电子病历信息查询接口（查询时间最新的那条数据）--按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthMarInfo> queryElecRecord(HealthMarInfo healthMarInfo) {
        return healthMarInfoMapper.queryElecRecord(Long.valueOf(healthMarInfo.getRecordid()), healthMarInfo.getIdNumber());

    }
    //新规则查询当下时间往前12个月的就诊数据作为电子病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthMarInfo> newQueryElecRecord(HealthMarInfo healthMarInfo) {
        return healthMarInfoMapper.newQueryElecRecord(Long.valueOf(healthMarInfo.getRecordid()),healthMarInfo.getSeeId(),healthMarInfo.getIdNumber());

    }

    //新规则：除去当下时间往前12个月的就诊数据，剩下的数据为既往病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthMarInfo> newQueryPastRecord(HealthMarInfo healthMarInfo) {
        return healthMarInfoMapper.newQueryPastRecord(Long.valueOf(healthMarInfo.getRecordid()),healthMarInfo.getSeeId(),healthMarInfo.getIdNumber());

    }
    
}
